//
//  YBDuesPayTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by apple on 17/8/5.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "YBDuesPayTableViewCell.h"

@interface YBDuesPayTableViewCell ()
//标题
@property (nonatomic , strong) UILabel * cellTitleLabel;
//最近催缴
@property (nonatomic , strong) UILabel * nearUrgedTimeLabel;
//描述说明
@property (nonatomic , strong) UILabel * myCellDetailLabel;

@end

@implementation YBDuesPayTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initMyCell];
    }
    return self;
}




-(void)initMyCell{
    TenGrayShadowView *under = [[TenGrayShadowView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 10 * [UIScreen zj_screenHScale])];
    under.backgroundColor = [UIColor themeGrayColor];
    under.isRemoveTop = YES;
    [self.contentView addSubview:under];
    //logo
    UIImageView * logoImageView = [[UIImageView alloc]initWithFrame:CGRectMake(ItemWidth * 24, ItemHeight * 45, ItemHeight * 39, ItemHeight * 39)];
    logoImageView.image = [UIImage imageNamed:@"mine_con_dfjn"];
    [self.contentView addSubview:logoImageView];
    
    [self.contentView addSubview:self.cellTitleLabel];
    [self.contentView addSubview:self.nearUrgedTimeLabel];
    [self.contentView addSubview:self.myCellDetailLabel];

    self.nearUrgedTimeLabel.sd_layout.leftSpaceToView(self.contentView , ItemWidth * 74).topSpaceToView(self.cellTitleLabel , ItemHeight * 26).widthIs(ItemWidth * 650).heightIs(ItemHeight * 39);
    
    self.myCellDetailLabel.sd_layout.leftSpaceToView(self.contentView , ItemWidth * 74).topSpaceToView(self.nearUrgedTimeLabel , 0).widthIs(ItemWidth * 650).heightIs(ItemHeight * 70);
    
//    UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 4)];
//    lineView.backgroundColor = [UIColor whiteColor];
//    lineView.layer.shadowOffset = CGSizeMake(0, 2);
//    lineView.layer.shadowColor = [UIColor blackColor].CGColor;
//    lineView.layer.shadowOpacity = 0.2;
//    [self.contentView addSubview:lineView];
//    
//    
//    
//    lineView.sd_layout.leftSpaceToView(self.contentView , 0).bottomEqualToView(self.contentView).widthIs([UIScreen zj_screenWith]).heightIs(4);
    
    
}

-(void)setModel:(BranchNormalModel *)model
{
    _model = model;
    YBBranchNoticeModel * tempModel = (YBBranchNoticeModel *)model;
    self.cellTitleLabel.frame = CGRectMake(ItemWidth * 74, self.titleBeginY + 20 * ItemHeight, ItemWidth * 642, model.titleHeight);
    self.cellTitleLabel.attributedText = model.titleAttributedString;
    NSString * timeString = tempModel.ASKTIME;
    timeString = [timeString componentsSeparatedByString:@"."][0];
    if (timeString.length > 0) {
        timeString = [NSDateFormatter formatterDateStringWithoutHourAndMinWithDateString:timeString];
    }
    NSString * askTimeString = timeString;
    NSString * deptsecretaryNameString = tempModel.DEPTSECRETARY_NAME;
    NSString * showString = @"";
    if (askTimeString.length == 0 && deptsecretaryNameString.length == 0) {
        showString = @"最近催缴：（无）";
    }
    else{
        if (askTimeString.length == 0) {
            showString = [NSString stringWithFormat:@"最近催缴：（%@）" , deptsecretaryNameString];
        }
        else if(deptsecretaryNameString.length == 0){
            showString = [NSString stringWithFormat:@"最近催缴：%@" , askTimeString];
        }
        else{
            showString = [NSString stringWithFormat:@"最近催缴：%@ （%@）" , askTimeString , deptsecretaryNameString];
        }
    }
    self.nearUrgedTimeLabel.text = showString;
    self.myCellDetailLabel.text = @"请联系书记交党费";

}





//标题
-(UILabel *)cellTitleLabel
{
    if (!_cellTitleLabel) {
        _cellTitleLabel = [ToolClass creatLabelWithFrame:CGRectMake(ItemWidth * 74, ItemHeight * 25, ItemWidth * 642, ItemHeight * 39) font:16 textColor:[UIColor textBlackColor] text:@""];
    }
    return _cellTitleLabel;
}
//最近催缴
-(UILabel *)nearUrgedTimeLabel
{
    if (!_nearUrgedTimeLabel) {
        _nearUrgedTimeLabel = [ToolClass creatLabelWithFrame:CGRectMake(ItemWidth * 74, ItemHeight * 90, ItemWidth * 650 , ItemHeight * 39) font:14 textColor:[UIColor textBlackColor] text:@""];
    }
    return _nearUrgedTimeLabel;
}

//描述说明
-(UILabel *)myCellDetailLabel
{
    if (!_myCellDetailLabel) {
        _myCellDetailLabel = [ToolClass creatLabelWithFrame:CGRectMake(ItemWidth * 74, ItemHeight * 110, ItemWidth * 650 , ItemHeight * 39) font:20 textColor:[UIColor zj_colorWithHexString:@"ff7200"] text:@""];
    }
    return _myCellDetailLabel;
}


@end
